﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<script>
    // 1.创建核心对象
    var xhttp;
    if (window.XMHttpRequest) {
        xhttp = new XMLHttpRequest();
    } else {
        // code for IE6,IE5
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    // 2.发送请求
    xhttp.open("GET", "http://localhost:8080/ajax-demo/ajaxServlet");
    xhttp.send();
    // 3.获取响应
    xhttp.onreadystatethange = function () {
        if (this.readystate == 4 && this.status == 200) {
            alert(this.responseText);
        }
    }
</script>
</body>
</html>